package max.ubitest.pipe.view
{
	import flash.events.Event;
	
	import max.ubitest.pipe.Config;
	import max.ubitest.pipe.locators.CellLocator;
	
	import mx.events.FlexEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	public class CellContainerMediator extends Mediator
	{
		[Inject]
		public var view:CellContainer;
		[Inject]
		public var locator:CellLocator;
		
		public function CellContainerMediator()
		{
			super();
		}
		
		override public function onRegister():void{
			onInit();
		}
		
		override public function preRemove():void{
			
		}
		
		private function onInit():void{
			for(var i:int = 0;i<locator.cells.length;i++){
				var cell:CellRenderer = new CellRenderer();
				cell.data = locator.cells.getItemAt(i);
				cell.x = cell.data.x * Config.CELL_SIZE;
				cell.y = cell.data.y * Config.CELL_SIZE;
				
				view.addElement(cell);
			}
		}
	}
}